#ifndef __SERVO_H
#define __SERVO_H
#include "sys.h"

#define Servo_TotalNumber 2
#define ServoPWM_Timer TIM1
#define ServoChannel0 PBout(7)
#define ServoChannel1 PBout(8)

void Servo_PWM_init(u16 arr,u16 psc);
void TIM1_PWM_adjust(void);
void Servo_PositionMode_Calc(void);
void Servo_SpeedMode_Calc(void);
void Servo_Control(void);
void Servo_Reset(void);

extern u16 System_Time_Counter;
extern unsigned char PWM1Control;
extern unsigned char Flag_ServoAdjust;
extern unsigned char Flag_ServoLock;
extern unsigned char PWM1Reverse;
extern unsigned char Servo_ControlMode;

extern int ServoPWM_Max[Servo_TotalNumber];
extern int ServoPWM_Min[Servo_TotalNumber];
extern int ServoPWM_Default[Servo_TotalNumber];
extern u16 ServoPWM_Out[Servo_TotalNumber];
extern int ServoAngle_Max[Servo_TotalNumber];
extern int ServoAngle_Default[Servo_TotalNumber];
extern int ServoAngle_Min[Servo_TotalNumber];
extern float PS2_ServoPosition[Servo_TotalNumber];//细化之后的PS2位置数组，0-1800；
extern float SpeedRatio[5];
extern int Rate_FromAngleToPWM;
extern u8 Servo_AdjustRoutine;

#endif
